<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>C++ Web Framework: Filter Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">C++ Web Framework
   &#160;<span id="projectnumber">3.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="class_filter-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Filter Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>The <a class="el" href="class_filter.html" title="The Filter class works like a filter. You can use this class to validate sessions or measuring runtim...">Filter</a> class works like a filter. You can use this class to validate sessions or measuring runtime of a specific method, for example. To use this class, you will need to create a derived class and reconstruct the doFilter method, after this, you will need to configure it into the ConfigureCppWebServer, using the setFilter method.  
 <a href="class_filter.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="filter_8h_source.html">filter.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:aa37dc017d133404b3a326f363ce36b8a"><td class="memItemLeft" align="right" valign="top"><a id="aa37dc017d133404b3a326f363ce36b8a"></a>
virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_filter.html#aa37dc017d133404b3a326f363ce36b8a">~Filter</a> ()</td></tr>
<tr class="memdesc:aa37dc017d133404b3a326f363ce36b8a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Virtual destructor. <br /></td></tr>
<tr class="separator:aa37dc017d133404b3a326f363ce36b8a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7648d16d5bc8cc5c95c072f34e507f7f"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_filter.html#a7648d16d5bc8cc5c95c072f34e507f7f">doFilter</a> (CWF::Request &amp;request, CWF::Response &amp;response, <a class="el" href="class_filter_chain.html">FilterChain</a> &amp;chain)</td></tr>
<tr class="memdesc:a7648d16d5bc8cc5c95c072f34e507f7f"><td class="mdescLeft">&#160;</td><td class="mdescRight">This method will be called always that the <a class="el" href="class_cpp_web_server.html" title="The CppWebServer class is a HTTP server, responsable to receive and dispatch the requisitions. ">CppWebServer</a> receives a requisition.  <a href="#a7648d16d5bc8cc5c95c072f34e507f7f">More...</a><br /></td></tr>
<tr class="separator:a7648d16d5bc8cc5c95c072f34e507f7f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>The <a class="el" href="class_filter.html" title="The Filter class works like a filter. You can use this class to validate sessions or measuring runtim...">Filter</a> class works like a filter. You can use this class to validate sessions or measuring runtime of a specific method, for example. To use this class, you will need to create a derived class and reconstruct the doFilter method, after this, you will need to configure it into the ConfigureCppWebServer, using the setFilter method. </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="a7648d16d5bc8cc5c95c072f34e507f7f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7648d16d5bc8cc5c95c072f34e507f7f">&#9670;&nbsp;</a></span>doFilter()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void Filter::doFilter </td>
          <td>(</td>
          <td class="paramtype">CWF::Request &amp;&#160;</td>
          <td class="paramname"><em>request</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">CWF::Response &amp;&#160;</td>
          <td class="paramname"><em>response</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="class_filter_chain.html">FilterChain</a> &amp;&#160;</td>
          <td class="paramname"><em>chain</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>This method will be called always that the <a class="el" href="class_cpp_web_server.html" title="The CppWebServer class is a HTTP server, responsable to receive and dispatch the requisitions. ">CppWebServer</a> receives a requisition. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">request</td><td>: This is a reference to the <a class="el" href="class_request.html" title="The Request class holds all information about a http request. ">Request</a>. </td></tr>
    <tr><td class="paramname">response</td><td>: This is a reference to the <a class="el" href="class_response.html" title="The Response class is responsable to response a Http request. ">Response</a>. </td></tr>
    <tr><td class="paramname">chain</td><td>: This is a reference to the <a class="el" href="class_filter_chain.html" title="The FilterChain class is responsable to dispatch a requisition. This class was built to work with Fil...">FilterChain</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section user"><dt>Example</dt><dd><div class="fragment"><div class="line"><span class="comment">//----loginfilter.h-----</span></div><div class="line"></div><div class="line"><span class="preprocessor">#ifndef LOGINFILTER_H</span></div><div class="line"><span class="preprocessor">#define LOGINFILTER_H</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;cwf/filter.h&quot;</span></div><div class="line"></div><div class="line"><span class="keyword">class </span>LoginFilter : <span class="keyword">public</span> CWF::Filter</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line">    <span class="keywordtype">void</span> <a class="code" href="class_filter.html#a7648d16d5bc8cc5c95c072f34e507f7f">doFilter</a>(CWF::Request &amp;request, CWF::Response &amp;response, CWF::FilterChain &amp;chain)</div><div class="line">    {</div><div class="line">        QString url = request.getRequestURL();</div><div class="line">        <span class="keywordflow">if</span>(url.endsWith(<span class="stringliteral">&quot;.css&quot;</span>) || url.endsWith(<span class="stringliteral">&quot;.png&quot;</span>) || url.endsWith(<span class="stringliteral">&quot;.jpg&quot;</span>))</div><div class="line">        {</div><div class="line">            chain.doFilter(request, response);</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span>(url != <span class="stringliteral">&quot;/login&quot;</span>)</div><div class="line">        {</div><div class="line">            <span class="keywordflow">if</span>(request.getSession().getAttribute(<span class="stringliteral">&quot;user&quot;</span>) == <span class="keyword">nullptr</span> || request.getSession().isExpired())</div><div class="line">            {</div><div class="line">                request.getRequestDispatcher(<span class="stringliteral">&quot;/pages/login&quot;</span>).forward(request, response);</div><div class="line">            }</div><div class="line">            <span class="keywordflow">else</span></div><div class="line">            {</div><div class="line">                chain.doFilter(request, response);</div><div class="line">            }</div><div class="line">         }</div><div class="line">         <span class="keywordflow">else</span></div><div class="line">         {</div><div class="line">             chain.doFilter(request, response);</div><div class="line">         }</div><div class="line">    }</div><div class="line">};</div><div class="line"></div><div class="line"><span class="preprocessor">#endif // LOGINFILTER_H</span></div><div class="line"></div><div class="line"><span class="comment">//----main.h-----</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;filter/loginfilter.h&gt;</span></div><div class="line"><span class="preprocessor">#include &quot;cwf/cppwebapplication.h&quot;</span></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div><div class="line">{</div><div class="line">    CWF::CppWebApplication server(argc,</div><div class="line">                                  argv,</div><div class="line">                                  <span class="stringliteral">&quot;PATH_TO_SERVER_FOLDER&quot;</span>,</div><div class="line">                                  <span class="keyword">new</span> LoginFilter);</div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> server.start();</div><div class="line">}</div></div><!-- fragment --> </dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>/home/herik/CPPWebFramework/CPPWebFramework/cwf/<a class="el" href="filter_8h_source.html">filter.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Mon May 28 2018 11:09:09 for C++ Web Framework by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
